<?php 

$toPrint = '<h3>Login</h3>';
$toPrint .= '<div class="textwidget">';
$toPrint .= '<div id="weather">';
$toPrint .= '<form style="overflow:hidden" method="post" action="index.php" onSubmit="return validateLogin()">';
$toPrint .= '<label>Username:</label>';
$toPrint .= '<span style="background:url(wp-content/themes/theme1273/images/search-text.gif) no-repeat left top; font-size:12px; height:21px; width:150px; margin-right:2px; float:left;">';

$toPrint .= '<input type="text" style="width:145px; background:none; border:none; padding:3px 5px; font-size:12px;" name="userLogin"> ';
$toPrint .= '</span> <br><br>';

$toPrint .= '<label>Password:</label>';
$toPrint .= '<span style="background:url(wp-content/themes/theme1273/images/search-text.gif) no-repeat left top; font-size:12px; height:21px; width:150px; margin-right:2px; float:left;">';

$toPrint .= '<input type="password" style="width:145px; background:none; border:none; padding:3px 5px; font-size:12px;" name="pwdLogin" >';

$toPrint .= '</span><br> <br> <br>';  

$toPrint .= '<input type="submit" value="" class="submit" style="color:white; background-color:#000000; border:none;  cursor:pointer; background-image:url(wp-content/themes/theme1273/images/submit.png); width:62px; height:21px;">';

$toPrint .= '<input type="button" class="submit" style="color:white; cursor:pointer;  background-color:#000000; border:none; background-image:url(wp-content/themes/theme1273/images/register.png); width:62px; height:21px; position:relative; right:-22px" onClick="writeRegistrationForm()">';

$toPrint .= '</form> </div> </div>';

if (isset($_SESSION['username']))
	if ($_SESSION['username'] != 'noSet'){
		
		$db = new DBManager ( 'localhost', 'root', '', 'iumus' );
		$query="SELECT COUNT(*) AS si, Saldo FROM utente WHERE Username ='".$_SESSION['username']."' AND Password = '".$_SESSION['pws']."' AND Activated = 0";
		$result=$db->executeQuery ($query);
		
		$row = mysql_fetch_array ( $result );
		if( $row['si'] == 1 ){
			if ($_SESSION['username'] == 'admin')
				header("Location: wp-admin/");
			$toPrint = '<h3>Welcome - '.$_SESSION['username'].'</h3>';
			$toPrint .= '<div class="textwidget"><div id="weather"> 
			<table width="100%">
				<tr><td ><a class="someclassname" href="profile.php">My Profile</a></td></tr>
				<tr><td ><a class="someclassname" href="messages.php">My Messages</a></td></tr>
				<tr><td >CREDIT: '.$row['Saldo'].' €</td></tr>
				<tr><td style="border: none"><a class="someclassname" href="payment.php">Credit Charge</a></td></tr>
				<tr><td style="border: none"><a class="someclassname" href="watchList.php">My Watchlist</a</td></tr>
				<tr><td style="border: none"><a class="someclassname" href="films.php">My Films</td></a>
			</table>
			
			</div><a class="someclassname" href="index.php?esco=true&sed='.rand(10000,999999).'"><img src="wp-content/themes/theme1273/images/logout.png" /></a></div>';
		}
		else{ 
			$_SESSION['username'] = 'noSet';
			echo '<script type="text/javascript">noLogJS = true;</script>';
		}
	}
echo $toPrint;

?>
<style type="text/css">
	.someclassname:hover {
	 	text-decoration:underline;
	}
	.someclassname {
	  text-decoration:none;
	}
</style>
